<?php

namespace App\Store\Models\Sysset;

use App\Common\Services\Common;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;

class SigninUsemoney extends Model
{
    protected $table = 'site_sysset_signin_usemoney';
    public $timestamps = false;
    protected $primaryKey = 'id';
    protected $guarded = ['_token'];

    /**
     * 获取列表
     */
    public static function getList(Request $request)
    {
        $query = self::where(['cp_id' => $request['cp_id'], 'is_del' => 1])->orderBy('create_at', 'desc');

        $isgetall = $request['isgetall'] ?? 0;
        if ($isgetall == 0) {
            $limit = $request->limit ?? 10;
            $list = $query->paginate($limit)->toArray();
            return Common::paginateDataToArray($list);
        } else {
            $list = $query->get()->toArray();
            return ['list' => $list];
        }
    }
}
